home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat1 / grep.z / grep
Encoding:
Text File  |  2002-10-03  |  15.6 KB  |  331 lines

  1.  
  2.  
  3.  
  4. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _gggg_rrrr_eeee_pppp - search a file for a pattern
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_bbbb_hhhh_iiii_nnnn_ssss_vvvv_xxxx_yyyy_CCCC] _----_eeee _p_a_t_t_e_r_n__l_i_s_t [_----_ffff
  13.      _p_a_t_t_e_r_n__f_i_l_e]. . .[_f_i_l_e . . .]
  14.  
  15.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_bbbb_hhhh_iiii_nnnn_ssss_vvvv_xxxx_yyyy_CCCC][_----_eeee _p_a_t_t_e_r_n__l_i_s_t] _----_ffff
  16.      _p_a_t_t_e_r_n__f_i_l_e]. . .[_f_i_l_e . . .]
  17.  
  18.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_bbbb_hhhh_iiii_nnnn_ssss_vvvv_xxxx_yyyy_CCCC] _p_a_t_t_e_r_n__l_i_s_t[_f_i_l_e . . .]
  19.  
  20. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      The _g_r_e_p utility searches the input files, selecting lines matching one
  22.      or more patterns; the types of patterns are controlled by the options
  23.      specified.  The patterns are specified by the _----_eeee option, _----_ffff option, or
  24.      the _p_a_t_t_e_r_n__l_i_s_t operand. The _p_a_t_t_e_r_n__l_i_s_t's value consists of one or
  25.      more patterns separated by newline characters; the _p_a_t_t_e_r_n__f_i_l_e's
  26.      contents consist of one or more patterns terminated by newline
  27.      characters.  By default, an input line will be selected if any pattern,
  28.      treated as an entire basic regular expression (BRE) as described in the
  29.      _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _B_a_s_i_c _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s,
  30.      matches any part of the line; a null BRE will match every line. By
  31.      default, each selected input line will be written to the standard output.
  32.  
  33.      Regular expression matching will be based on text lines.  Since a newline
  34.      character separates or terminates patterns (see the _----_eeee and _----_ffff options
  35.      below), regular expressions cannot contain a newline character.
  36.      Similarly, since patterns are matched against individual lines of the
  37.      input, there is no way for a pattern to match a newline character found
  38.      in the input.
  39.  
  40.      Command line options are:
  41.  
  42.  
  43.      _----_EEEE      Match using extended regular expressions. Treat each pattern
  44.              specified as an ERE, as described in the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page
  45.              under the section titled:  _E_x_t_e_n_d_e_d _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s.  If any
  46.              entire ERE pattern matches an input line, the line will be
  47.              matched. A null ERE matches every line.
  48.  
  49.      _----_FFFF      Match using fixed strings.  Treat each pattern specified as a
  50.              string instead of a regular expression. If an input line contains
  51.              any of the patterns as a contiguous sequence of bytes, the line
  52.              will be matched. A null string matches every line.
  53.  
  54.      _----_bbbb      Precede each output line by the block number within the input
  55.              file where it was found.  The first (512 byte) block is number 0.
  56.  
  57.      _----_cccc      Write only a count of selected lines to standard output.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  71.  
  72.  
  73.  
  74.      _----_eeee _p_a_t_t_e_r_n__l_i_s_t
  75.              Specify one or more patterns to be used during the search for
  76.              input. Patterns in _p_a_t_t_e_r_n__l_i_s_t must be separated by a newline
  77.              character.  A null pattern can be specified by two adjacent
  78.              newline characters in _p_a_t_t_e_r_n__l_i_s_t. Unless the _----_EEEE or _----_FFFF option is
  79.              also specified, each pattern will be treated as a BRE, as
  80.              described in the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled:
  81.              _B_a_s_i_c _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s. Multiple _----_eeee and _----_ffff options are
  82.              accepted by the _g_r_e_p utility.  All of the specified patterns are
  83.              used when matching lines, but the order of evaluation is
  84.              unspecified.
  85.  
  86.      _----_ffff _p_a_t_t_e_r_n__f_i_l_e
  87.              Read one or more patterns from the file named by the pathname
  88.              pattern_file.  Patterns in _p_a_t_t_e_r_n__f_i_l_e are terminated by a
  89.              newline character.  A null pattern can be specified by an empty
  90.              line in _p_a_t_t_e_r_n__f_i_l_e.  Unless the _----_EEEE or _----_FFFF option is also
  91.              specified, each pattern will be treated as a BRE, as described in
  92.              the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _B_a_s_i_c _R_e_g_u_l_a_r
  93.              _E_x_p_r_e_s_s_i_o_n_s.
  94.  
  95.      _----_hhhh      Suppress the name of the file containing the matching line from
  96.              being printed on output when multiple files are searched.
  97.  
  98.      _----_iiii      Perform pattern matching in searches without regard to case. See
  99.              the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _R_e_g_u_l_a_r
  100.              _E_x_p_r_e_s_s_i_o_n _G_e_n_e_r_a_l _R_e_q_u_i_r_e_m_e_n_t_s.
  101.  
  102.      _----_llll      Write only the names of files containing selected lines to
  103.              standard output.  Pathnames are written once per file searched.
  104.              If the standard input is searched, a pathname of "(_ssss_tttt_aaaa_nnnn_dddd_aaaa_rrrr_dddd
  105.              _iiii_nnnn_pppp_uuuu_tttt)" will be written, in the POSIX locale.  In other locales,
  106.              _ssss_tttt_aaaa_nnnn_dddd_aaaa_rrrr_dddd _iiii_nnnn_pppp_uuuu_tttt may be replaced by something more appropriate in
  107.              those locales.
  108.  
  109.      _----_nnnn      Precede each output line by its relative line number in the file,
  110.              each file starting at line 1. The line number counter will be
  111.              reset for each file processed.
  112.  
  113.      _----_qqqq      Quiet.  Do not write anything to the standard output, regardless
  114.              of matching lines. Exit with zero status if an input line is
  115.              selected.
  116.  
  117.      _----_ssss      Suppress the error messages ordinarily written for non-existent
  118.              or unreadable files. Other error messages will not be suppressed.
  119.  
  120.      _----_vvvv      Select lines not matching any of the specified patterns.  If the
  121.              _----_vvvv option is not specified, selected lines will be those that
  122.              match any of the specified patterns.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  137.  
  138.  
  139.  
  140.      _----_xxxx      Consider only input lines that use all characters in the line to
  141.              match an entire fixed string or regular expression to be matching
  142.              lines.
  143.  
  144.      _----_yyyy      Obsolescent option.  Same as _----_iiii.
  145.  
  146.      _----_CCCC      Obsolete option.  Unused.
  147.  
  148.  
  149. OOOOPPPPEEEERRRRAAAANNNNDDDDSSSS
  150.      The following operands are supported:
  151.  
  152.  
  153.      _p_a_t_t_e_r_n
  154.           Specify one or more patterns to be used during the search for input.
  155.           This operand is treated as if it were specified as _----_eeee _p_a_t_t_e_r_n__l_i_s_t.
  156.  
  157.      _f_i_l_e A pathname of a file to be searched for the patterns.  If no _f_i_l_e
  158.           operands are specified, the standard input will be used.
  159.  
  160. SSSSTTTTDDDDIIIINNNN
  161.      The standard input will be used only if no _f_i_l_e operands are specified.
  162.      See _IIII_NNNN_PPPP_UUUU_TTTT _FFFF_IIII_LLLL_EEEE_SSSS.
  163.  
  164. IIIINNNNPPPPUUUUTTTT FFFFIIIILLLLEEEESSSS
  165.      The input files must be text files.
  166.  
  167. SSSSTTTTDDDDOOOOUUUUTTTT
  168.      If the _----_llll option is in effect, and the _----_qqqq option is not, the following
  169.      will be written for each file containing at least one selected input
  170.      line:
  171.  
  172.           "%s\n", _f_i_l_e
  173.  
  174.      Otherwise, if more than one _f_i_l_e argument appears, and the _----_qqqq and _----_hhhh
  175.      options are not set, the _g_r_e_p utility will prefix each output line by:
  176.  
  177.           "%s:", _f_i_l_e
  178.  
  179.      The remainder of each output line depends on the other options specified:
  180.  
  181.  
  182.      _oooo  If the _----_cccc option is in effect, the remainder of each output line will
  183.         contain:
  184.  
  185.              "%d\n", <_c_o_u_n_t>
  186.  
  187.  
  188.      _oooo  If _----_cccc is not in effect and the _----_nnnn option is in effect, the _g_r_e_p
  189.         utility will prefix each output line by:
  190.  
  191.              "%d:", <_l_i_n_e _n_u_m_b_e_r>
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  203.  
  204.  
  205.  
  206.      _oooo  If _----_cccc is not in effect and the _----_bbbb option is in effect, the _g_r_e_p
  207.         utility will prefix each output line by:
  208.  
  209.              "%d:", <_b_l_o_c_k _n_u_m_b_e_r>
  210.  
  211.  
  212.      _oooo  Finally, the following will be written to standard output:
  213.  
  214.              "%s", <_s_e_l_e_c_t_e_d-_l_i_n_e _c_o_n_t_e_n_t_s>
  215.  
  216.  
  217. SSSSTTTTDDDDEEEERRRRRRRR
  218.      Used only for diagnostic messages.
  219.  
  220. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  221.      _eeee_dddd(1), _eeee_gggg_rrrr_eeee_pppp(1), _ffff_gggg_rrrr_eeee_pppp(1), _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5), _ssss_eeee_dddd(1), _ssss_hhhh(1)
  222.  
  223. EEEEXXXXIIIITTTT SSSSTTTTAAAATTTTUUUUSSSS
  224.      Exit status is 0 if any matches are found, 1 if none, >1 for syntax
  225.      errors or inaccessible files (even if matches were found).
  226.  
  227. CCCCOOOONNNNSSSSEEEEQQQQUUUUEEEENNNNCCCCEEEESSSS OOOOFFFF EEEERRRRRRRROOOORRRRSSSS
  228.      If the _----_qqqq option is specified, the exit status will be zero if an input
  229.      line is selected, even if an error was detected.
  230.  
  231.      If the requested action cannot be performed on a file, _gggg_rrrr_eeee_pppp will issue a
  232.      diagnostic message to standard error and continue processing the next
  233.      operand in sequence, but the final exit status is returned as non-zero.
  234.  
  235. AAAAPPPPPPPPLLLLIIIICCCCAAAATTTTIIIIOOOONNNN UUUUSSSSAAAAGGGGEEEE
  236.      Care should be taken when using characters in _p_a_t_t_e_r_n__l_i_s_t that may also
  237.      be meaningful to the command interpreter. It is safest to enclose the
  238.      entire _p_a_t_t_e_r_n__l_i_s_t argument in single quotes:
  239.  
  240.  
  241.      The _----_eeee _p_a_t_t_e_r_n__l_i_s_t option has the same effect as the _p_a_t_t_e_r_n__l_i_s_t
  242.      operand, but is useful when _p_a_t_t_e_r_n__l_i_s_t begins with the hyphen
  243.      delimiter. It is also useful when it is more convenient to provide
  244.      multiple patterns as separate arguments.
  245.  
  246.      Multiple _----_eeee and _----_ffff options are accepted and _g_r_e_p will use all of the
  247.      patterns it is given while matching input text lines. (Note that the
  248.      order of evaluation is not specified. If an implementation finds a null
  249.      string as a pattern, it is allowed to use that pattern first, matching
  250.      every line, and effectively ignore any other patterns.)
  251.  
  252.      The _----_qqqq option provides a means of easily determining whether or not a
  253.      pattern (or string) exists in a group of files.  When searching several
  254.      files, it provides a performance improvement (because it can quit as soon
  255.      as it finds the first match) and requires less care by the user in
  256.      choosing the set of files to supply as arguments (because it will exit
  257.      zero if it finds a match even if _g_r_e_p detected an access or read error on
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  269.  
  270.  
  271.  
  272.      earlier file operands).
  273.  
  274. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  275.      1.   To find all uses of the word Posix in a bunch of files where some of
  276.           the files cannot be opened due to permission restrictions:
  277.  
  278.                _g_r_e_p -_q -_n _P_o_s_i_x /_e_t_c/*
  279.  
  280.           Note the above use of the -_q command line option to _g_r_e_p.  If the -_q
  281.           is not used in the above command line, then when the first file is
  282.           encountered that is not readable _g_r_e_p will error terminate even if
  283.           there were some matches found.
  284.  
  285.      2.   To find all uses of the word Posix (in any case) in file _tttt_eeee_xxxx_tttt_...._mmmm_mmmm and
  286.           write with line numbers:
  287.  
  288.                _g_r_e_p -_i -_n _p_o_s_i_x _t_e_x_t._m_m
  289.  
  290.  
  291.      3.   To find all empty lines in the standard input:
  292.  
  293.                _g_r_e_p ^$
  294.                or:
  295.                _g_r_e_p -_v .
  296.  
  297.  
  298.      4.   Both of the following commands print all lines containing strings
  299.           _aaaa_bbbb_cccc or _dddd_eeee_ffff or both:
  300.  
  301.                _g_r_e_p -_E '_a_b_c
  302.                _d_e_f'
  303.                _g_r_e_p -_F '_a_b_c
  304.                _d_e_f'
  305.  
  306.  
  307.      5.   Both of the following commands print all lines matching exactly _aaaa_bbbb_cccc
  308.           or _dddd_eeee_ffff:
  309.  
  310.                _g_r_e_p -_E '_a_b_c$
  311.                ^_d_e_f$'
  312.                _g_r_e_p -_F -_x '_a_b_c
  313.                _d_e_f'
  314.  
  315.  
  316. BBBBUUUUGGGGSSSS
  317.      If there is a line with embedded nulls, _gggg_rrrr_eeee_pppp will only match up to the
  318.      first null; if it matches, it will print the entire line.
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.